<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../../assets/font/iconfont.css">
    <style>
        .icon-order {
            font-size: 22px;
        }

        .aside-box {
            position: fixed;
            top: 0px;
            left: 0px;
            /* height: 100%;
            width: 100%; */
            height: 100vh;
            width: 100vw;
            background-color: rgba(0, 0, 0, 0.4);
            transition: all 500ms ease;
        }

        .aside-nav {
            background-color: #0d072d;
            width: 70vw;
            /* min-height: 50vh; */
            color: white;
            /* 当元素正常显示于页面时，部分非瞬时样式发生改变，可以执行的动画 */
            transition: all 500ms ease;
        }
        .aside-nav .item{
            display: flex;
            flex-flow: row nowrap;
            justify-content: space-between;
            padding: 16px;
            border-bottom: 2px solid #1a213d;
            font-size: 18px;
            cursor: pointer;
            user-select: none;
        }
        .aside-nav .item.title{
            font-size: 22px;
            color: #0474b5;
            font-weight: bold;
        }
        .aside-nav .item:last-child{
            /* unset 取消设置 */
            border-bottom: unset;
        }
        .aside-nav .item > .iconfont{
            font-size: 24px;
        }
        .aside-nav .item.title > .iconfont{
            color: white;
            font-size: 28px;
            font-weight: normal;
        }
    </style>
</head>

<body>
    <div id="app">
        <button @click="openAsside()">
            <span class="iconfont icon-order"></span>
        </button>

        <!-- 
            :style=" isShow?'opacity:1':'opacity:0' "
        -->
        <div class="aside-box" 
            :style=" isShow?'':'display:none' " 
            @click="closeAsside()"
        >
        <!-- :style=" `transform:translate(${ isShow?'0%':'-100%' },0);` " -->
            <aside class="aside-nav" 
                @click.stop
                :style=" `transform:translate(${ pos },0);` "
            >
                <div class="title item">
                    <span>热门课程</span>
                    <i class="iconfont icon-close" @click="closeAsside()"></i>
                </div>
                <div class="item">
                    <span>
                        <i class="iconfont icon-email-fill"></i>
                        课程名称
                    </span>
                    <i class="iconfont icon-right"></i>
                </div>
                <div class="item">
                    <span>
                        <i class="iconfont icon-email-fill"></i>
                        课程名称
                    </span>
                    <i class="iconfont icon-right"></i>
                </div>
                <div class="item">
                    <span>
                        <i class="iconfont icon-email-fill"></i>
                        课程名称
                    </span>
                    <i class="iconfont icon-right"></i>
                </div>
                <div class="item">
                    <span>
                        <i class="iconfont icon-email-fill"></i>
                        课程名称
                    </span>
                    <i class="iconfont icon-right"></i>
                </div>
                <div class="item">
                    <span>
                        <i class="iconfont icon-email-fill"></i>
                        课程名称
                    </span>
                    <i class="iconfont icon-right"></i>
                </div>
                <div class="item">
                    <span>
                        <i class="iconfont icon-email-fill"></i>
                        课程名称
                    </span>
                    <i class="iconfont icon-right"></i>
                </div>
            </aside>
        </div>

    </div>
    <script type="module">
        import { createApp } from "../../assets/vue3/vue.esm-browser.js";
        createApp({
            data() {
                return {
                    isShow:false,
                    pos:"-100%"
                }
            },
            methods:{
                openAsside(){
                    this.isShow = true;
                    setTimeout(() => {
                        this.pos = "0%";
                    }, 10);
                },
                closeAsside(){
                    this.pos = "-100%";
                    setTimeout(() => {
                        this.isShow = false;
                    }, 510);
                }
            }
        }).mount("#app");
    </script>
</body>

</html>